import request from '@/utils/request'

export function queryRole(data, { currentPage, size }) {
  return request({
    url: `/system/role/list/${currentPage}/${size}`,
    method: 'post',
    data
  })
}
export function queryAllRole() {
  return request({
    url: `/system/role/findAll`,
    method: 'get',
  })
}
// 新增角色
export function addRole(data) {
  return request({
    url: '/system/role',
    method: 'post',
    data
  })
}
// 修改角色
export function updateRoleApi(data) {
  return request({
    url: '/system/role',
    method: 'put',
    data
  })
}
// 角色详情
export function queryRoleDetail(id) {
  return request({
    url: `/system/role/${id}`,
    method: 'get'
  })
}
// 删除角色
export function deleteRole(id) {
  return request({
    url: `/system/role/${id}`,
    method: 'delete'
  })
}














// 查询当前角色菜单权限
export function queryRoleMenu(data) {
  return request({
    url: '/sysRoleMenu/search',
    method: 'post',
    data
  })
}

// 保存当前角色菜单权限
export function saveRoleMenu(data) {
  return request({
    url: '/sysRoleMenu',
    method: 'post',
    data
  })
}

// 保存当前角色菜单权限
export function findUserByRoleId(data, { currentPage, size }) {
  return request({
    url: `/sysUser/findUserByRoleId/${currentPage}/${size}`,
    method: 'post',
    data
  })
}

export function queryRoleLink(params) {
  return request({
    url: '/queryRoleLink',
    method: 'get',
    params
  })
}

/** 增 */
export function createTableDataApi(data) {
  return request({
    url: 'table',
    method: 'post',
    data
  })
}

/** 删 */
export function deleteTableDataApi(id) {
  return request({
    url: `table/${id}`,
    method: 'delete'
  })
}

/** 改 */
export function updateTableDataApi(data) {
  return request({
    url: 'table',
    method: 'put',
    data
  })
}
